Sensor Fusion for Kinetis MCUs (ISSDK/KSDK version)
driver_pit.c File Reference
+ Include dependency graph for driver_pit.c:

Go to the source code of this file.

Macros

#define PIT_LED_HANDLER   PIT0_IRQHandler
 
#define PIT_IRQ_ID   PIT0_IRQn
 
#define PIT_SOURCE_CLOCK   CLOCK_GetFreq(kCLOCK_BusClk)
 

Functions

void PIT_LED_HANDLER (void)
 
void pit_init (uint32_t microseconds)
 

Variables

volatile bool pitIsrFlag = false
 

Detailed Description

Bare metal implementations of the sensor fusion library require at least one periodic interrupt for use as a timebase for sensor fusion functions. The Periodic Interval Timer (PIT) is one such module that is commonly found on NXP Kinetis MCUs. The PIT functions are only referenced at the main() level. There is no interaction within the fusion routines themselves.

Definition in file driver_pit.c.

Macro Definition Documentation

#define PIT_IRQ_ID   PIT0_IRQn

Definition at line 50 of file driver_pit.c.

Referenced by pit_init().

#define PIT_LED_HANDLER   PIT0_IRQHandler

Definition at line 49 of file driver_pit.c.

#define PIT_SOURCE_CLOCK   CLOCK_GetFreq(kCLOCK_BusClk)

Definition at line 51 of file driver_pit.c.

Referenced by pit_init().

Function Documentation

void pit_init ( uint32_t  microseconds)

Definition at line 62 of file driver_pit.c.

Referenced by main().

63 {
64  /* initialize PIT */
65  pit_config_t pitConfig; // Declare KSDK PIT configuration structure
66  PIT_GetDefaultConfig(&pitConfig); // Fill out that structure with defaults
67  PIT_Init(PIT, &pitConfig); // PIT is declared by the KSDK
68  // We choose to use Channel 0 of the PIT. That can obviously be changed
69  PIT_SetTimerPeriod(PIT, kPIT_Chnl_0, USEC_TO_COUNT(microseconds, PIT_SOURCE_CLOCK));
70  PIT_EnableInterrupts(PIT, kPIT_Chnl_0, kPIT_TimerInterruptEnable);
71  EnableIRQ(PIT_IRQ_ID);
72  PIT_StartTimer(PIT, kPIT_Chnl_0);
73 }
#define PIT_IRQ_ID
Definition: driver_pit.c:50
#define PIT_SOURCE_CLOCK
Definition: driver_pit.c:51

+ Here is the caller graph for this function:

void PIT_LED_HANDLER ( void  )

Definition at line 55 of file driver_pit.c.

56 {
57  /* Clear interrupt flag.*/
58  PIT_ClearStatusFlags(PIT, kPIT_Chnl_0, PIT_TFLG_TIF_MASK);
59  pitIsrFlag = true;
60 }
volatile bool pitIsrFlag
Definition: driver_pit.c:53

Variable Documentation

volatile bool pitIsrFlag = false

Definition at line 53 of file driver_pit.c.

Referenced by main(), and PIT_LED_HANDLER().